package spider;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import org.jsoup.Jsoup;

/**
 * 拉勾网的爬取工具
 */
public class LagouSpider {
    public static void main(String[] args) {
        String url = "https://gate.lagou.com/v1/neirong/kaiwu/getCourseLessonDetail?lessonId=1026";

        HttpRequest request = HttpUtil.createGet(url);
        request.cookie("user_trace_token=20210206180947-448e775e-d47e-4998-a9bb-054d9bc4614b; _ga=GA1.2.1839303387.1612606188; LGUID=20210206180947-d9e1bb2b-acf6-4d5f-8ebd-de80f77a145d; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1612606188,1612606226; index_location_city=%E5%85%A8%E5%9B%BD; smidV2=202102061818313ad40bcae22f49bb17177d5e6ce3757400e6e991b73c3e6f0; thirdDeviceIdInfo=%5B%7B%22channel%22%3A1%2C%22thirdDeviceId%22%3A%22WHJMrwNw1k/FSAVPc4cE7IGE3XnjQBbvXUxE/2vfHh7b70Nflc6Z8r/PA5S0uRRwXq/pZTAYdS+rY3To1ty0U7GgBjZ0WfhWrdCW1tldyDzmQI99+chXEigAsirSe2QLE9lCUKKcsmkTaFO8webhNijYmmmXo8LlTkQE5YcNLqNriNYPfoOP/bkkCzK117ErOtGngXtXMBJD5sFQHfyb6PTiM5iSMAfwceztEqmvu8qpU/sx9VvKOk6gBBGOZdDG/F10/rPYNoNw%3D1487582755342%22%7D%2C%7B%22channel%22%3A2%2C%22thirdDeviceId%22%3A%22140%23t6FogJqfzzPFeQo23zNb4pN8s7O4A35VCL73JJWtjAhyd0AYb6DNxG+ThoPQLrlnHVTLu6hqzznU65oye3fzzFzUijlqlQzx2DD3VthqzFcs2O8+lpYazDrbV2Qbo3oOONdOHaU+PQbxfIRAMwlFUGD6qB2WkzVrFivZYxR5XqjUEOEnz03Uy9wVhMXDgzWCA3MMFcafsbps1GprZbOBzvmQMU51ll/siX2lh6PPnF3W26jJ7bemzOGFxfatrN3wNk8oZ5jCFhzwuFO9WqrpkuzFy+IbmxVAYTp4Ng19SuFnJu9mNKlDs3pWI7qQCqgVuju44R8Fiq5Ku62rkXdL9ZdAH4rx7uIB45p5+duAsOvPTg81rNsknQixduSCC1TX36grjvKLsWA28EfUsoFJse1bT4Z3BggXb8w35qxqG5wH0DkKyaVUoldIKRbwG08KT4vdAZwbdoVw8zm0hXyknpet1Avx/VIJjyYIIcUQqEfQppxrODdV9pKgYmEkcimTB/v8XWoYmetNZ1L23CCZbqIJ5ak/22Cm3J8Y6HLIMlFRaAHbfPb8V7JrvNJ3eEkK5sk5bEZ7MyPRdFrqBKXPZmsZzVOIEnZZc+v/XTvyZcaF+cIDnxXlHaBKjEnWSPZX5m9dQLOJRdKNeAVNdUGyR0r+SXRFTx7Nlns9UFIKhcPA2CdcL2B2lYbRkbzEUx3MdLErNmNHco9+LujVacEZsJu5bbkXS9jiwThEFwOS52HcIP4/FyaHGVvXaB+zuyzvs3K/vlYs4hDH2jvyrO8vlZJKxCbcuraBVqOlPOnpxkYGsZqFhVCNdG+pBWJBkMnT184cHGKJKwMowpTMVNEsWvwwiNyy8kBrIGZVp73QuC1fJQdHoBywhDACo7k1oWa4+7zWiN39EwWMGSLEZoK4YVFJLVMSfl+%3D%2Cundefined%22%7D%5D; user-finger=59aecf9c91f55b2a8f1fcb04eae4d121; LG_LOGIN_USER_ID=27ce4ae4d554c7e59e7e6783489428c7eb74a0068e9b361cb3b06d5566c37803; LG_HAS_LOGIN=1; sensorsdata2015session=%7B%7D; SESSION=a56a338d-71f5-413f-a34c-fd03ccd6f52c; EDUJSESSIONID=ABAAAECABCAAACD204E201E1BD774D30C0DED3427A7ABCE; kw_login_authToken=\"LDm5wIBNu0pzGeJUYZd25xw3ue3fSSODODLMSuzEp7ubX78BrJbKEsod5POaU8vC9LZn4hKgAVPMZHySFO9cGTwKssx8KZIQ6HXVcuJM5QEzqqFRk0gNvUOunKP8uLhXYdLNjOpctTfc+ytsDG/mRXxaol3dGjB2QXzXUquXQEF4rucJXOpldXhUiavxhcCELWDotJ+bmNVwmAvQCptcy5e7czUcjiQC32Lco44BMYXrQ+AIOfEccJKHpj0vJ+ngq/27aqj1hWq8tEPFFjdnxMSfKgAnjbIEAX3F9CIW8BSiMHYmPBt7FDDY0CCVFICHr2dp5gQVGvhfbqg7VzvNsw==\"; gate_login_token=bf16e5c47549d0be3484be46c3893a0ccaa4963c6d0cee4e7958a29b6db1d4f4; X_HTTP_TOKEN=e94d99d5ed3a15e70728203161e7f4521d584a2776; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2220514828%22%2C%22first_id%22%3A%2217776d23e6720e-0248baba5e72f6-b34356b-2073600-17776d23e68e08%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_utm_source%22%3A%22baidujava%22%2C%22%24latest_utm_medium%22%3A%22pcst%22%2C%22%24latest_utm_term%22%3A%22spcc001%22%2C%22%24os%22%3A%22Windows%22%2C%22%24browser%22%3A%22Chrome%22%2C%22%24browser_version%22%3A%2265.0.3325.181%22%7D%2C%22%24device_id%22%3A%2217776d23e6720e-0248baba5e72f6-b34356b-2073600-17776d23e68e08%22%7D; JSESSIONID=0330DEBEC9090976D8A7569187A2EC88");
        request.header("x-l-req-header", "{deviceType:1}");
        request.header("authorization", "bf16e5c47549d0be3484be46c3893a0ccaa4963c6d0cee4e7958a29b6db1d4f4");
        HttpResponse response = request.execute();
        String ss = response.body();
        String htmlStr = JSONUtil.parseObj(ss).getJSONObject("content").getStr("textContent");
        System.out.println(Jsoup.parse(htmlStr).text());
    }
}
